﻿using B.S.Base.Read.API.Application.Command;
using MediatR;
using WEBAPI.Damoin;
using WEBAPI.ErroeCode;
using WEBAPI.Indaseture.Infasetures;

namespace B.S.Base.Read.API.Application.CommandHandLer
{
    public class GetQueryPidCommandHandLer : IRequestHandler<GetQueryPidCommand, APIResult<bool>>
    {
        private readonly IBaseRepostiy<MenuModel> menu;

        public GetQueryPidCommandHandLer(IBaseRepostiy<MenuModel> menu)
        {
            this.menu = menu;
        }
        public async Task<APIResult<bool>> Handle(GetQueryPidCommand request, CancellationToken cancellationToken)
        {
            var list = menu.GetAll().Where(x => x.Pid == request.Id).Any();
            return new APIResult<bool>
            {
                Code = ResultCode.Ok,
                Message = "获取成功",
                Data = list
            };
        }
    }
}
